/**************************
* @Summary
* @Author 20009200303 赵传博
* @Date 2022/4/26
*****************************/

#include "Test.h"

void Test::testTree() {

    string word;
    cin >> word;
    if(word != "0"){
        auto* root = new Tnode(word);
        auto* tree = new Tree(root);
        cin >> word;
        while(word != "0"){
            tree->insertNode(word, root);
            cin >> word;
        }
        cout << "Trees: " << endl;
        tree->printTree(root);
        cout << endl << "Inorder: " << endl;
        tree->printInOrder(root);
    }

}

void Test::testExpr() {
    while(true){
        string str;
        cin >> str;
        const char *exp = str.c_str();
        //cout << exp;
        Expr expr(exp);
        cout << "inOrder: ";
        expr.print_mid();
        if(expr.getRoot()->getTokType() != ASSIGNEND){
            cout << "postFix: ";
            expr.print_postfix();
            cout << "preFix: ";
            expr.print_prefix();
            cout << "Result: " << expr.calculateVal() << endl;
        }
    }
    //cout << endl << "Test:";
    //cout << Token_type(expr.getRoot()->getTokType());
}
